package easy.多数元素;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Solution2 {
    public int majorityElement(int[] nums) {
        Arrays.sort(nums);
        return nums[nums.length / 2];
    }


    public static void main(String[] args) {
        int[] nums = {3, 2, 3};
        int[] nums2 = {2, 2, 1, 1, 1, 2, 2};
        Solution2 solution = new Solution2();
        System.out.println(solution.majorityElement(nums));
        System.out.println(solution.majorityElement(nums2));
    }
}
